package com.livesource.client.web.liveTaskBoard;

import com.google.gwt.user.client.ui.VerticalPanel;
import com.livesource.client.LiveSourceGlobalVariables;
import com.livesource.client.webservices.project.RequestGetProject;

public class InitializeLiveTaskBoard {

	public static VerticalPanel vpTaskBoard = new VerticalPanel();

	public static VerticalPanel getPanel(String userID, String projectSelectedID) {

		LiveSourceGlobalVariables.currentUserID = userID;

		vpTaskBoard.clear();

		vpTaskBoard.add(new LiveTaskBoard());

		if (LiveSourceGlobalVariables.currentProject == null
				|| !projectSelectedID
						.equals(LiveSourceGlobalVariables.currentProject
								.getProjectID())) {

			LiveSourceGlobalVariables.projectEntries = null;

			RequestGetProject.getJsonpRequest(projectSelectedID);

		} else {

			loadPanel();
		}

		return vpTaskBoard;
	}

	public static void loadPanel() {

		BoardPanel.showTasks(LiveSourceGlobalVariables.projectEntries);
	}

}
